﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AutoUpdateMgr.Mgr
{
    using AutoUpdateMgr.Mgr.Handler;
    public class HandlerMgr
    {
        #region Instance

        public static HandlerMgr instance { set; get; } = null;

        public static HandlerMgr getInstance()
        {
            if (instance == null)
            {
                instance = new HandlerMgr();
            }

            return instance;
        }

        #endregion

        public void doAction(AutoUpdate.Model.Packet.Packet packet)
        {
            try
            {
                Console.WriteLine(packet.CommandText);

                if (packet.CommandText == "createVersion")
                {
                    new createVersionHandler().doAction(packet);
                }
                else if (packet.CommandText == "uploadFile")
                {
                    new uploadFileHandler().doAction(packet);
                    //new getClientListHandler().doAction(packet);
                }
                else if (packet.CommandText == "getVersions")
                {
                    new getVersionsHandler().doAction(packet);
                    //new getClientListHandler().doAction(packet);
                }
                else if (packet.CommandText == "getVersion")
                {
                    new getVersionHandler().doAction(packet);
                    //new getClientListHandler().doAction(packet);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}
